package com.hsb.dao;

import com.hsb.entity.Book;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BookDao {
    //增加一条记录
    @Insert("insert into book(name,count,detail) values(#{name},#{count},#{detail})")
    int insert(Book book);

    //根据id删除记录
    @Delete("delete from book where id=#{id}")
    int deleteById(int id);

    //根据id查询记录
    @Select("select * from book where id=#{id}")
    Book queryById(int id);

    //查询所有记录
    @Select("select * from book")
    List<Book> queryAll();

    //根据id修改记录
    @Update("update book set name=#{name},count=#{count},detail=#{detail} where id=#{id}")
    int updateById(Book book);
}